/*
 * TMap Designer - A Thematic Map design software
 * Copyright (C) 2006 World Health Organization
 * http://www.who.int
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */
package who.tmap.ui.util;

import who.tmap.bo.AttrDef;

/**
 * Store column info for edit data structure
 * 
 * @see JDialogEditDataStructure
 * @see EditDataStructureTableModel
 * @author stl
 *
 */
public class DataStructureColumnInfo {

	private String originalName;
	private String updatedName;
	private String originalType;
	private String updatedType;
	private boolean deleted;
	private boolean neww;
	private AttrDef attrDef;
	
	public DataStructureColumnInfo() {
		originalType =String.class.getName();
		updatedType =new String( originalType );
	}
	
	public DataStructureColumnInfo( AttrDef attrDef ) {
		this.attrDef =attrDef;
		this.originalName =new String( attrDef.getName() );
		this.updatedName =new String( originalName );
		this.originalType =new String( attrDef.getType() );
		this.updatedType =new String( originalType );		
	}

	public boolean isDeleted() {
		return deleted;
	}

	public void setDeleted(boolean deleted) {
		this.deleted = deleted;
	}	

	public boolean isNeww() {
		return neww;
	}

	public void setNeww(boolean neww) {
		this.neww = neww;
	}

	public String getOriginalName() {
		return originalName;
	}

	public void setOriginalName(String originalName) {
		this.originalName = originalName;
	}

	public String getOriginalType() {
		return originalType;
	}

	public void setOriginalType(String originalType) {
		this.originalType = originalType;
	}

	public String getUpdatedName() {
		return updatedName;
	}

	public void setUpdatedName(String updatedName) {
		this.updatedName = updatedName;
	}

	public String getUpdatedType() {
		return updatedType;
	}

	public void setUpdatedType(String updatedType) {
		this.updatedType = updatedType;
	}	
	
	public AttrDef getAttrDef() {
		return attrDef;
	}

	public void setAttrDef(AttrDef attrDef) {
		this.attrDef = attrDef;
	}

	public boolean isUpdated() {
		return deleted || !originalName.equalsIgnoreCase( updatedName )
					   || !originalType.equalsIgnoreCase( updatedType );
	}
}
